package logic

import (
	"gitee.com/huanminabc/go-StrMathCalculate/register"
	"gitee.com/huanminabc/go-StrMathCalculate/structure"
	"strconv"
)

type EqArithmeticCalculate struct {
	name          string                  //计算器名称
	priority      int                     //优先级
	calculateData structure.CalculateData //计算器数据
	result        string                  //计算结果

}

func init() {
	//注册计算器
	register.RegisterCalculate(&EqArithmeticCalculate{
		name:     "==",
		priority: 4,
	})
}

func (a *EqArithmeticCalculate) GetName() string {
	return a.name
}

func (a *EqArithmeticCalculate) IsBool(symbol string) bool {
	if symbol == a.name {
		return true
	}
	return false
}

func (a *EqArithmeticCalculate) AddExpression(a1, symbol, b1 string) {
	a.calculateData = structure.CalculateData{
		A:      a1,
		Symbol: symbol,
		B:      b1,
	}
}

func (a *EqArithmeticCalculate) Calculate() {
	a.result = strconv.FormatBool(a.calculateData.A == a.calculateData.B)
}

func (a *EqArithmeticCalculate) GetResult() string {
	return a.result
}

func (a *EqArithmeticCalculate) GetPriority() int {
	return a.priority
}
